<?php
//1. 跨域
header("access-control-allow-origin:*");
//2. 包含文件
include_once("./utils/db.php");
include_once("./utils/functions.php");

//3. sql
$sql = "update xk_course set coursename=?,credit=?, period=?, content=? where courseid=?";
//4. 创建stmt
$stmt = mysqli_prepare($conn, $sql);
//5. 从浏览器获取修改的值
$coursename = $_POST["coursename"];
$credit = $_POST["credit"];
$period = $_POST["period"];
$content = $_POST["content"];
$courseid = $_POST["courseid"];
//6. 绑定值
$stmt->bind_param("siisi", $coursename, $credit, $period, $content, $courseid);

$info = [];
//7. 执行
if ($stmt->execute() === TRUE) {
  $info = ["code" => 200, "msg" => "更新成功"];
} else {
  $info = ["code" => 0, "msg" => "更新失败"];
}
echo json_encode($info, JSON_UNESCAPED_UNICODE);
